package com.jx.springcloud.controller;

import com.jx.springcloud.entiy.CommentResult;
import com.jx.springcloud.entiy.User;
import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@RestController
public class OrderControl {
    @Resource
    RestTemplate restTemplate;

    public final static String URL = "http://CLOUND-PAYMENT-SERVICE";

    @GetMapping(value = "/consumer/getUser/{id}")
    public CommentResult<User> getUser(@PathVariable("id") Long id) {
        return restTemplate.getForObject(URL + "/getUser/" + id, CommentResult.class, id);
    }

    @GetMapping(value = "/consumer/insertUser")
    public CommentResult<User> insertUser(User user) {
        System.out.println(user);
        return restTemplate.postForObject(URL + "/insertUser", user, CommentResult.class);
    }
}
